<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>02_借用构造函数继承</title>
</head>
<body>
<!-- 
方式2：借用构造函数继承
    * 套路
        * 定义父类型构造函数
        * 定义子类型构造函数
        * 在子类型构造函数中调用父类型构造
    * 关键
        * 在子类型构造函数中调用call()或者apply()调用父类型构造函数
-->
<script>
function Person(name, age) {
    this.name = name
    this.age = age
}

function Student(name, age, score) {
    // Person.call(this, name, age)
    Person.apply(this, [name, age])
    this.score = score
}

var s1 = new Student("Tom", 18, 100)
console.log(s1.name, s1.age, s1.score)
</script>

</body>
</html>